import { httpGet, handleResult } from "./http";
import moment from "moment";

//列表
export async function pageList(params) {
  const url = "/gm_course/list";
  // return await httpGet(url, params).then(res => res.data.data);
  return await httpGet(url, params).then(res => {
    res.data.data.list.map(p => {
      if (p.classAt) p.classAt = moment(new Date(p.classAt)).format("YYYY-MM-DD");
      p.createAt = null;
      p.updateAt = null;
    });
    return res.data.data;
  });
}
//更新
export async function update(data) {
  const url = "/gm_course/update";
  return await httpGet(url, data).then(handleResult);
}
//逻辑删除 flag 1物理删除，!1逻辑删除
export async function remove(id, flag) {
  const url = "/gm_course/delete";
  let res = await get(url, { id, flag });
  return res.success;
}
